<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app"></div>
    <script>
        let com = {
            template:`
            <div>
                <ul>
                    <li @click="fun('苹果')">苹果</li>
                    <li @click="fun('李子')">李子</li>
                    <li @click="fun('香蕉')">香蕉</li>
                    <li @click="fun('葡萄')">葡萄</li>
                </ul>
            </div>
            `,
            methods:{
                fun(name){
                    this.$emit('set',name)
                }
            }
        }
        let app = {
            template:`
            <div>
                <p>客户点了:{{ str }}</p>
                <com @set="fun"></com>
            </div>
            `,
            components:{ com },
            data(){
                return{
                    str:'1'
                }
            },
            methods:{
                fun(name){
                    this.str = name
                }
            }
        }
        new Vue({
            render:function(h){
                return h(app)
            }
        }).$mount('#app')
    </script>
</body>
</html>